package com.hqyj.entity.common;
import org.apache.commons.lang3.StringUtils;

//进行分页排序的类
public class SearchBean {

    //初始页面时给默认值
    public final static int DEFAULT_CURRENT_PAGE = 1;
    public final static int DEFAULT_PAGE_SIZE = 5;

    //显示当前页数
    private int currentPage;
    //每页显示的多少条数据
    private int pageSize;
    //模糊查询时进行的关键字匹配
    private String keyWord;
    //排序时的列名
    private String orderBy;
    //排序的方式（正序反序）
    private String direction;

    public void initSearchBean() {
        if (this.getCurrentPage() == 0) {
            this.setCurrentPage(DEFAULT_CURRENT_PAGE);
        }
        if (this.getPageSize() == 0) {
            this.setPageSize(DEFAULT_PAGE_SIZE);
        }
        //判断如果是空就设置为desc反向排序
        if (StringUtils.isBlank(this.getDirection())) {
            this.setDirection("desc");
        }
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }
}
